package com.mz.ozy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.mz.ozy.R;
import com.mz.ozy.bean.UsdtDetailBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 *
 */

public class UsdtDetailAdapter extends RecyclerView.Adapter<UsdtDetailAdapter.MyViewHolder> {


    private Context mContext;
    List<UsdtDetailBean.PageBean.PageItemsBean> mBeanList;

    public UsdtDetailAdapter(Context context, List<UsdtDetailBean.PageBean.PageItemsBean> mBeanList) {
        mContext = context;
        this.mBeanList = mBeanList;

    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_balance_detail, parent, false));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {

 /*       amt(金额),type(账单类型:0-充币 1-提币 2-手动调整 3-c2c买入 4-c2c卖出 5-c2c取消返回 6-兑换 7-转账 8-转账手续费
     9-商品购买 10-解冻扣除 11-通证静态收益 12-复投静态收益
    13-通证分享收益 14-复投分享收益 15-通证团队收益 16-复投团队收益 17-申述返回 18-申述服务费返回),
        stype(收支类型:0-收入 1-支出),
        mtype(金额类型 0-USDT 1-通证积分 2-复投积分 3-消费积分 4-期权积分 5-股权积分),created(订单日期)*/

        UsdtDetailBean.PageBean.PageItemsBean bean = mBeanList.get(position);
        int sztype = bean.getStype();
        if (sztype == 0) {
            holder.tvMoney.setText("+" + bean.getAmt());
        } else if (sztype == 1) {
            holder.tvMoney.setText("-" + bean.getAmt());
        }
        holder.tvDate.setText(bean.getCreated());
        int lxtype = bean.getType();
     /*   账单类型:0-充币 1-提币 2-手动调整 3-c2c买入 4-c2c卖出 5-c2c取消返回 6-兑换
    7-转出 8-转账手续费 9-商品购买 10-解冻扣除
    11-通证静态收益 12-复投静态收益 13-通证分享收益
    14-复投分享收益 15-通证团队收益 16-复投团队收益 17-申述返回 18-申述服务费返回 19-转入*/
        switch (lxtype) {
            case 0:
                holder.tvRemark.setText("充币");
                break;
            case 1:
                holder.tvRemark.setText("提币");

                break;
            case 2:
                holder.tvRemark.setText("手动调整");

                break;
            case 3:
                holder.tvRemark.setText("c2c买入");

                break;
            case 4:
                holder.tvRemark.setText("c2c卖出");

                break;
            case 5:
                holder.tvRemark.setText("c2c取消返回");

                break;
            case 6:
                //金额类型 0-USDT 1-通证积分 2-复投积分 3-消费积分 4-期权积分 5-股权积分
                if (bean.getMtype() == 0) {
                    holder.tvRemark.setText("USDT兑换");

                } else if (bean.getMtype() == 1) {
                    if (sztype == 0) {
                        holder.tvRemark.setText("USDT兑换");

                    } else {
                        holder.tvRemark.setText("KT兑换");

                    }

                } else if (bean.getMtype() == 4) {
                    holder.tvRemark.setText("兑换股权积分");

                } else if (bean.getMtype() == 5) {
                    if (sztype == 0) {
                        holder.tvRemark.setText("期权积分兑换");

                    } else {
                        holder.tvRemark.setText("兑换USDT");
                    }

                }
                break;
            case 7:
                holder.tvRemark.setText("转出-" + bean.getUsername());

                break;
            case 8:
                holder.tvRemark.setText("转账手续费");

                break;
            case 9:
                holder.tvRemark.setText("商品购买");

                break;
            case 10:
                holder.tvRemark.setText("解冻扣除");

                break;
            case 11:
                holder.tvRemark.setText("KT静态收益");

                break;
            case 12:
                holder.tvRemark.setText("复投静态收益");

                break;
            case 13:
                holder.tvRemark.setText("KT分享收益");

                break;
            case 14:
                holder.tvRemark.setText("复投分享收益");

                break;
            case 15:
                holder.tvRemark.setText("KT团队收益");

                break;
            case 16:
                holder.tvRemark.setText("复投团队收益");

                break;
            case 17:
                holder.tvRemark.setText("申述返回");

                break;
            case 18:
                holder.tvRemark.setText("申述服务费返回");

                break;
            case 19:
                holder.tvRemark.setText("转入-" + bean.getUsername());
                break;
            case 20:
                holder.tvRemark.setText("提币失败退币");
                break;
            case 21:
                if (sztype == 0) {
                    holder.tvRemark.setText("游戏币兑换");
                } else if (sztype == 1) {
                    holder.tvRemark.setText("兑换游戏币");
                }
                break;
            case 22:
                holder.tvRemark.setText("C2C卖出手续费");
                break;
            case 23:
                holder.tvRemark.setText("取消手续费返还");
                break;
            case 24:
                holder.tvRemark.setText("股权分红");
                break;
            case 25:
                holder.tvRemark.setText("商品购买退款");
                break;
        }

    }

    @Override
    public int getItemCount() {
        return mBeanList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_remark)
        TextView tvRemark;
        @BindView(R.id.tv_date)
        TextView tvDate;
        @BindView(R.id.tv_money)
        TextView tvMoney;
        @BindView(R.id.ll_item)
        LinearLayout llItem;

        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }


    }


}
